// FSR testing

int fsrPin = 0;     // the FSR and 10K pulldown are connected to a0
int fsrReading;     // the analog reading from the FSR resistor divider
int fsrVoltage;     // the analog reading converted to voltage
unsigned long fsrResistance;  // The voltage converted to resistance, can be very big so make "long"
unsigned long fsrConductance; 
long fsrForce;       // Finally, the resistance converted to force
 
void setup(void) {
  Serial.begin(9600);   // We'll send debugging information via the Serial monitor
}
 
void loop(void) {
  fsrReading = analogRead(fsrPin);  
  
  fsrVoltage =  fsrReading*5000/1024;
  
  // Once mapped, convert the output into resistance so that Force can be obtained
  if (fsrVoltage = 0) {
	Serial.print("No Force Detected");
  } 
  else {
	// use this formula to compute output voltage Vo = (RFSR/(R + RFSR))*Vin
	// RFSR = RVo / (Vi-Vo)
	fsrResistance = (1000*fsrVoltage)/(5000-fsrVoltage); // 5000 mV is the 5V input into the circuit and 1000 is the value of the resistance used.
	
	Serial.print(" FSR Resistance in Ohms = ");
	Serial.println(fsrResistance);
	}
}
	


